<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */

class b2c_ctl_admin_member2 extends desktop_controller{

    var $workground = 'b2c_ctl_admin_member2';
    var $pagelimit = 10;
    var $member_model ;
    public function __construct($app)
    {
        parent::__construct($app);
        $this->member_model = $this->app->model('members');
        header("cache-control: no-store, no-cache, must-revalidate");
    }
    
    //////////////////////
    	/**
    	 * add by 黄智坤 2017-4-6
    	 */
        public function confirm(){
//        	$this->test();
        	
        $this->finder('b2c_mdl_memberschange',array(
            'title'=>app::get('b2c')->_('变更信息列表'),
            'allow_detail_popup'=>true,
            'actions'=>array(
                            array('label'=>app::get('b2c')->_('通过'),'submit'=>'index.php?app=b2c&ctl=admin_member2&act=deal'),
                        	),
							'use_buildin_recycle'=>true,
							'use_buildin_filter'=>true,
							'use_view_tab'=>true,
            ));
    }
    
    
    	function deal(){
    		$this->begin('index.php?app=b2c&ctl=admin_member2&act=confirm');
    		$mdl_memchange = $this->app->model('memberschange');
		    $id['id']=$_POST['id'];
		    foreach($id['id'] as $key =>$v){
		    	
    		$res[$key]=$mdl_memchange->update(array('state'=>1),array('id'=>$v));
		    	$res2[$key]=$mdl_memchange->getList("*",array('id'=>$v));
		    }
			$this->end(true,'ok');

    	}
//    	$this->end(true, "广告添加成功！");
//					echo '<pre>';
//			 		echo '<br>===$res======<br>';
//		        	var_dump($res2);
////		        	exit;
    	
		function test(){
			$frname='abcdef';
			$pam_members_model = app::get('b2c')->model('members');
        	$flag = $pam_members_model->getList('*',array('frname'=>trim($frname)));
        		echo '<pre>';
			 		echo '<br>===$flag======<br>';
		        	var_dump($flag);
		        	exit;
		}
    
   		public function _views(){
    	$mdl_memchange = $this->app->model('memberschange');
    	$tags=array(
    	
    		0=>array(
    		'label'=>'待处理',
    		'filter'=>array('state'=>'0')
			),
			
    		1=>array(
    		'label'=>'已处理',
    		'filter'=>array('state'=>'1')
			)
			
    	);
    	
    	 foreach($tags as $key=>$value){
    	 	$sub_menu[]=array(
			'label'=>app::get('b2c')->_($value['label']),
			'optional'=>true,
			'filter'=>$value['filter'],
			'addon'=>$mdl_memchange->count($value['filter']),
			'href'=>'index.php?app=b2c&ctl=admin_member2&act=confirm&view='.$key.''
			);
    	 	
    	 }

    	return $sub_menu ;
    }
    
    

}
